package com.gjy.test.other;

import org.junit.jupiter.api.Test;

import java.text.DecimalFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.Month;
import java.time.Year;
import java.time.temporal.TemporalAdjusters;

/**
 * @author 宫静雨
 * @version 1.0
 * @since 2023-02-23 11:29:51
 */
public class T10 {

    @Test
    public void test6() {
        LocalDate now = LocalDate.now();
        Month month = now.getMonth();
        int length = month.length(now.isLeapYear());
        System.out.println("length = " + length);
    }

    @Test
    public void test5() {
        int length = Year.now().length();
        System.out.println(length);
    }

    @Test
    public void test4() {
        LocalDateTime now = LocalDateTime.now();

        int dayOfYear = now.getDayOfYear();
        System.out.println("dayOfYear = " + dayOfYear);
    }

    @Test
    public void test3() {
        int second = LocalDateTime.now().getSecond();
    }

    @Test
    public void test2() {
        LocalDate date = LocalDate.of(2023, 2, 24); // 指定日期
        int d1 = date.getDayOfMonth(); // 指定日期的天数
        int d2 = date.with(TemporalAdjusters.lastDayOfMonth()).getDayOfMonth(); // 指定日期月份最后一天

        System.out.println("(d2-d1) = " + (d2 - d1));
    }

    @Test
    public void test1() {
//3.75
//5.69
//4.720000000000001
        double v = (3.75 + 5.69) / 2;
        String format = new DecimalFormat().format(v);
        System.out.println("v = " + v);
        System.out.println("format = " + format);
    }
}
